﻿#include "mainwindow.h"
#include "ui_mainwindow.h"
#include "userregistrationform.h"
#include "networksettingform.h"
#include "devicesettingform.h"
#include "sensorsettingform.h"

MainWindow::MainWindow(QWidget *parent)
    : QMainWindow(parent)
    , ui(new Ui::MainWindow)
{
    ui->setupUi(this);
    connect(ui->New,SIGNAL(triggered()),this,SLOT(New()));
    connect(ui->Save,SIGNAL(triggered()),this,SLOT(Save()));
    connect(ui->Open,SIGNAL(triggered()),this,SLOT(Open()));

    connect(ui->Network,SIGNAL(triggered()),this,SLOT(NetworkSetting()));
    connect(ui->Devices,SIGNAL(triggered()),this,SLOT(DevicesSetting()));
    connect(ui->Sensors,SIGNAL(triggered()),this,SLOT(SensorsSetting()));

    connect(ui->User,SIGNAL(triggered()),this,SLOT(UserRegistration()));
    connect(ui->Version,SIGNAL(triggered()),this,SLOT(Version()));

}

void MainWindow::New()
{
   this->close();
}

void MainWindow::SensorsSetting()
{
    SensorSettingForm *SensorSetting = new SensorSettingForm();
    SensorSetting->setWindowTitle(QString::fromLocal8Bit("传感器参数设置"));
    SensorSetting->setAttribute(Qt::WA_ShowModal,true);//模态窗口
    SensorSetting->show();
}
void MainWindow::Save()
{
   this->close();
}
void MainWindow::UserRegistration()
{
   UserRegistrationForm *userForm=new UserRegistrationForm();
   userForm->setWindowTitle(QString::fromLocal8Bit("用户注册"));
   userForm->setAttribute(Qt::WA_ShowModal,true);//模态窗口
   userForm->show();
}
void MainWindow::Open()
{
   this->close();
}
void MainWindow::NetworkSettiong()
{
   NetworkSettingForm *NetSetting = new NetworkSettingForm();
   NetSetting->setWindowTitle(QString::fromLocal8Bit("网络参数设置"));
   NetSetting->setAttribute(Qt::WA_ShowModal,true);//模态窗口
   NetSetting->show();

}
void MainWindow::DevicesSetting()
{
    DeviceSettingForm *DeviceSetting = new DeviceSettingForm();
    DeviceSetting->setWindowTitle(QString::fromLocal8Bit("设备参数设置"));
    DeviceSetting->setAttribute(Qt::WA_ShowModal,true);//模态窗口
    DeviceSetting->show();
}


void MainWindow::Version()
{
   QMessageBox::warning(this, QString::fromLocal8Bit("软件版本号"),QString::fromLocal8Bit("version 1.0"),QMessageBox::Yes);
}
MainWindow::~MainWindow()
{
    delete ui;
}

